package com.mobileares.midp.widgets.client.panel;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2011-3-28
 * Time: 18:02:36
 * To change this template use File | Settings | File Templates.
 */
public class ContentPanel extends Composite {
    private EventFlowPanel panel;
    private SimplePanel content;
    private SimplePanel header;

    public ContentPanel(boolean hasHead) {
        panel = new EventFlowPanel();
        panel.setStyleName("panel-cp");
        initWidget(panel);
        if (hasHead) {
            initHead();
        }
        initContent();
    }

    public ContentPanel() {
        this(true);
    }

    private void initHead() {
        SimplePanel head = new SimplePanel();
        header = new SimplePanel();
        header.setStyleName("myhead-text");
        head.setStyleName("head");
        head.add(header);
        panel.add(head);
    }

    public void setHead(String text) {
        DOM.setInnerHTML(header.getElement(), text);
    }

    private void initContent() {
        content = new SimplePanel();
        content.setStyleName("content");

        panel.add(content);
    }

    public void setContent(Widget widget) {
        content.setWidget(widget);
    }

    public SimplePanel getHeader() {
        return header;
    }
}
